﻿@model Tuple<string,List<deviceManage.Models.DeviceType>>
@{
    Layout = null;
}
             <div class="layui-card">
                <div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="app-content-list">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">设备名称</label>
                            <div class="layui-input-inline" style="width:100px">
                                <input type="text" name="name" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">设备编号</label>
                            <div class="layui-input-inline"  style="width:100px">
                                <input type="text" name="deviceId" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">设备类型</label>
                            <div class="layui-input-inline"  style="width:100px">
                                <select name="deviceTypeId">
                                    <option></option>
                                    @foreach (var type in Model.Item2)
                                    {
                                    <option value="@type.Id">@type.Name</option>
                                    }
                                </select>
                            </div>
                        </div>
                          
                        <div class="layui-inline">
                            <button class="layui-btn layuiadmin-btn-list" lay-submit="" lay-filter="search">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                查询
                            </button>
                        </div>
                    </div>
                </div>
                <div class="layui-card-body">
                    <table id="deviceList" lay-filter="LAY-app-content-list"></table>
                </div>
               
            </div>
 
<script type="text/javascript" src="~/js/deviceState.js"></script>
<script>
     

    //加载table
    var tableSelectDevice = table.render({
        elem: '#deviceList'
        , url: '/checkLog/SelectDeviceList?id=@Model.Item1' //模拟接口
            ,method: 'post'
            , height:"300"
            , page: true
            , cols: [[

                 { field: 'name', title: '设备名称', width: 180, templet: '<div>{{d.name}}</div>'  }
                , { field: 'time', title: '设备类型', width: 100, templet: '<div>{{ d.deviceType.name}}</div>' }
                , { field: 'name', title: '规格型号', width: 280, templet: '<div>{{ d.model}}</div>' }
                , { field: 'name', title: '设备编号', width: 120, templet: '<div>{{ d.deviceId}}</div>' }
                , { field: 'name', title: '固定资产编号', width: 120, templet: '<div>{{ d.no}}</div>' }
                , { field: 'name', title: '所在机房', width: 120, templet: '<div>{{ d.room.name}}</div>' }
                , { field: 'name', title: '状态', width: 120, templet: '<div>{{ getDeviceState(d.status)}}</div>' }
                , { field: 'name', title: '采购日期', width: 120, templet: '<div>{{ getDate(d.buyDate)}}</div>' }
                , { field: 'name', title: '接管日期', width: 120, templet: '<div>{{ getDate(d.receiveDate)}}</div>' }
                , { field: 'name', title: '出保日期', width: 120, templet: '<div>{{ getDate(d.serviceDate) }}</div>' }
                , {
                    field: 'opr', title: '操作', width: 100, fixed:'right',
                templet:
                '<div class="layui-table-cell laytable-cell-11-0-8">'
                    + ' {{ getButtons2(d.id,d.status) }} '
                + '</div>'
            }
            ]]
            , skin: 'line'
    });
    window.parent.tableSelectDevice = tableSelectDevice;
    function getDate(d) {
        if (d != null) {
            return d.substring(0, 10);
        } else {
            return "";
        }
    }

    //根据状态获取不同的按钮
    function getButtons2(id, state) {
        var html = ' <a onclick="addDeviceCallback(\'' + id + '\')" class="layui-btn layui-btn-normal layui-btn-xs" ><i class="layui-icon layui-icon-add-1"></i>添加</a>';
        return html;
    }




    form.render(null, 'app-content-list');

    //监听搜索
    form.on('submit(search)', function (data) {
        var field = data.field;
        
        //执行重载
        table.reload('deviceList', {
            where: field
        });
    });
     
</script>

